package com.taotao.controller;

import com.taotao.common.pojo.BaseResult;
import com.taotao.common.utils.RedisUtils;
import com.taotao.service.*;
import com.taotao.trans.RobotTrans;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
public class CommonController {
	private static final Logger logger = LoggerFactory.getLogger(CommonController.class);
	
	@Autowired
	MessageInfoService messageInfoService;
	@Autowired
	SessionInfoService sessionInfoService;
	@Autowired
	MemberService memberService;
	@Autowired
	RobotService robotService;
	@Autowired
	GoodsService goodsService;
	@Autowired
	OperateLogService operateLogService;
	@Autowired
	RobotTrans robotTrans;
	@Autowired
	TaskService taskService;
	@Autowired
	ParamService paramService;

	BaseResult baseResult = new BaseResult();
	
	@RequestMapping("/common/commonController")
	@ResponseBody
	public Map<String, Object> commonController(@RequestBody Map<String, String> map, HttpServletRequest request) {
		logger.info("请求参数：" + map.toString());
		String method = map.get("method");
		Map<String, Object> resultMap = baseResult.getErrorMap("网络繁忙，请稍后再试");
		if ("queryMemberList".equals(method)) {  //发送get请求
			resultMap = memberService.queryMemberList(map);
		}
		
		if ("queryOperateList".equals(method)) {  //发送get请求
			resultMap = operateLogService.queryOperateList(map);
		}
		
		if ("queryGoodsList".equals(method)) {  //发送get请求
			resultMap = goodsService.queryGoodsList(map);
		}
		
		if ("queryMessageList".equals(method)) {  //发送get请求
			resultMap = messageInfoService.queryMessageList(map);
		}
		
		if ("querySessionList".equals(method)) {  //发送get请求
			resultMap = sessionInfoService.querySessionList(map);
		}
		
		if("modifyMember2".equals(method)){ //修改会员信息
			resultMap=memberService.modifyMember2(map);
		}
		
		if("getMemberById".equals(method)){ //获取会员信息
			resultMap=memberService.getMemberById(map);
		}
		
		if("robotMsg".equals(method)){ //机器人发送消息
			resultMap=robotTrans.robotMsg(map);
		}

		if ("queryParamList".equals(method)) {  //获取系统参数列表
			resultMap = paramService.queryParamList(map);
		}

		if ("getParam".equals(method)) {  //获取系统参数
			resultMap = paramService.getParam(map);
		}

		if ("modifyParam".equals(method)) {  //修改系统参数
			resultMap = paramService.modifyParam(map);
		}
		
	    return resultMap;
	}




}
